import React, { useEffect, useState } from 'react'
import { useParams, useLocation, useNavigate } from "react-router-dom"
import axios from 'axios';

export default function Index() {
  let [detail, setDetail] = useState("");
  let navigate = useNavigate();
  let res = useLocation();
  console.log(res);
  let { id } = useParams();
  useEffect(() => {
    console.log(id);
    (async () => {
      let { data } = await axios.get("/api/detail", { params: { id } });
      console.log(data);
      setDetail(data.content);
    })()
  })

  const goback = () => {
    navigate(-1);
  }

  return (
    <div>
      <button onClick={goback}>返回</button>
      <h1>{detail}</h1>
    </div>
  )
}
